package net.zoneland.knowledge.dao;

import java.util.List;
import net.zoneland.knowledge.model.UploadInfo;
import net.zoneland.knowledge.model.UploadInfoExample;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface UploadInfoMapper {
    @Delete({
        "delete from AITK_UPLOAD_INFO",
        "where ID = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    @Insert({
        "insert into AITK_UPLOAD_INFO (ID, FILE_NAME, ",
        "CONTENT_TYPE, CREATE_TIME, ",
        "CONTENT)",
        "values (#{id,jdbcType=VARCHAR}, #{fileName,jdbcType=VARCHAR}, ",
        "#{contentType,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{content,jdbcType=BLOB})"
    })
    int insert(UploadInfo record);

    @InsertProvider(type=UploadInfoSqlProvider.class, method="insertSelective")
    int insertSelective(UploadInfo record);

    @SelectProvider(type=UploadInfoSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="ID", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="FILE_NAME", property="fileName", jdbcType=JdbcType.VARCHAR),
        @Result(column="CONTENT_TYPE", property="contentType", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATE_TIME", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="CONTENT", property="content", jdbcType=JdbcType.BLOB)
    })
    List<UploadInfo> selectByExampleWithBLOBs(UploadInfoExample example);

    @SelectProvider(type=UploadInfoSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="ID", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="FILE_NAME", property="fileName", jdbcType=JdbcType.VARCHAR),
        @Result(column="CONTENT_TYPE", property="contentType", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATE_TIME", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<UploadInfo> selectByExample(UploadInfoExample example);

    @Select({
        "select",
        "ID, FILE_NAME, CONTENT_TYPE, CREATE_TIME, CONTENT",
        "from AITK_UPLOAD_INFO",
        "where ID = #{id,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="ID", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="FILE_NAME", property="fileName", jdbcType=JdbcType.VARCHAR),
        @Result(column="CONTENT_TYPE", property="contentType", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATE_TIME", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="CONTENT", property="content", jdbcType=JdbcType.BLOB)
    })
    UploadInfo selectByPrimaryKey(String id);

    @UpdateProvider(type=UploadInfoSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(UploadInfo record);

    @Update({
        "update AITK_UPLOAD_INFO",
        "set FILE_NAME = #{fileName,jdbcType=VARCHAR},",
          "CONTENT_TYPE = #{contentType,jdbcType=VARCHAR},",
          "CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},",
          "CONTENT = #{content,jdbcType=BLOB}",
        "where ID = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKeyWithBLOBs(UploadInfo record);

    @Update({
        "update AITK_UPLOAD_INFO",
        "set FILE_NAME = #{fileName,jdbcType=VARCHAR},",
          "CONTENT_TYPE = #{contentType,jdbcType=VARCHAR},",
          "CREATE_TIME = #{createTime,jdbcType=TIMESTAMP}",
        "where ID = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(UploadInfo record);
}